package com.java.controller;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Random;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.ibatis.annotations.Param;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;

import com.alibaba.druid.support.logging.Resources;
import com.java.utils.CommonUtils;
import com.java.utils.JsonBody;
import com.java.utils.ResponseUtil;
import com.java.utils.StringUtil;

public class Util {

	public static JsonBody SetMap(String msg,boolean  b)
	{
		JsonBody jb=new JsonBody();
		int code=b?0:1;
		String icon=b?"success":"error";
		jb.setCode(code);
		jb.setMsg(msg);
		jb.setSuccess(b);
		jb.setIcon(icon);
		return jb;
	}

	public static JsonBody SetOK(String msg)
	{
		JsonBody jb=new JsonBody();
		jb.setCode(0);
		jb.setMsg(msg);
		jb.setSuccess(true);
		jb.setIcon("success");
		return jb;
	}

	public static JsonBody SetError(String msg)
	{
		JsonBody jb=new JsonBody();
		jb.setCode(1);
		jb.setToken("");
		jb.setMsg(msg);
		jb.setSuccess(false);
		jb.setIcon("error");
		return jb;
	}

	public static JsonBody SetData(Object data,String msg)
	{
		JsonBody jb=new JsonBody();
		jb.setCode(0);
		jb.setMsg(msg);
		jb.setSuccess(true);
		jb.setIcon("success");
		jb.setData(data);
		return jb;
	}

	public static JsonBody SetData(Object data)
	{
		JsonBody jb=new JsonBody();
		jb.setCode(0);
		jb.setMsg("加载成功");
		jb.setSuccess(true);
		jb.setIcon("success");
		jb.setData(data);
		return jb;
	}
}


